﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OnlineCourse.Services;
using OnlineCourse.Services.Model;
using OnlineCourse.Model;
namespace OnlineCourse.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PayOrderController : ControllerBase
    {
        private readonly PayOrderService _payOrderService;
        public PayOrderController( ApplicationDbContext db)
        {
            this._payOrderService = new PayOrderService(db);
        }
        [HttpPost("Add")]
        public async Task<IActionResult> AddPayOrder(Guid PaymentTypeId, Guid UserId)
       
        {

            bool mark = false;
            int mes = 1000;
            mark = _payOrderService.AddPayOrder(out mes, PaymentTypeId, UserId);
            return Ok(new { mes=mes,mark=mark});
        }
        [HttpPost("GetList")]
        public async Task<IActionResult> getPayOrderlist(int page = 1, int pageSize = 10)
        {
            List<PayOrderQueryModel> list = null;
            int total = 0;
            list = _payOrderService.getPayOrderlist(out total, page, pageSize);
            
            return Ok(new { total=total,list=list});
        }
    }
}